package com.example.javabasic.thread.classtwo.activeobject.demo1;

/**
 * 将activeObjects 的方法转化为 Reqeust对象  MethodRequest 抽象类用于扩展,
 * {@link ActiveObjects#makeString(int, char)}
 */
public class MakeStringRequest extends MethodRequest {
    private final int count ;
    private final char fillChar;

    public MakeStringRequest(Servant servant, FutureResult futureResult,int count,char fillChar) {
        super(servant, futureResult);
        this.count = count;
        this.fillChar = fillChar;
    }

    /**
     *  执行任务,  并将结果引用放入request   的future中
     */
    @Override
    public void execute() {
        Result result = servant.makeString(count, fillChar);
        futureResult.setResult(result);
    }
}
